package layouts;

import java.awt.*;
import javax.swing.*;

public class LayoutTest extends JFrame {
	private Button button = new Button("Button");
	private TextArea textArea = new TextArea("TextArea");
	private JLabel label = new JLabel("Label");
	private Container container;
	
	public LayoutTest() {
		super("Layout test"); // Set the title using the superclass constructor
		
		setLayout(new TotalPercentLayout());
		
		button.setLocation(-50, -50); // That's underflow, so percent values will be 0
		button.setSize(30, 30);
		
		textArea.setLocation(50, 50);
		textArea.setSize(30, 30);
		
		label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
		label.setLocation(300, 300); // That's overflow, so percent values will be 100
		label.setSize(30, 30);
		
		container = getContentPane();

		container.add(button);
		container.add(textArea);
		container.add(label);
		
		setSize(800, 500);
		setLocationRelativeTo(null); // Moves the window to the center of the screen
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Closes the application when the window will be closed
		setVisible(true);
	}
	
	public static void main(String[] args) {
		new LayoutTest();
	}
}
